//
//  NetWorkBaseDao.m
//  singleTarget
//
//  Created by   李小云 on 17/9/21.
//  Copyright © 2017年   李小云. All rights reserved.
//

#import "NetWorkBaseDao.h"

@implementation NetWorkBaseDao


- (NSURLSessionTask *)httpRequestGetDataWithUrl:(NSString *)urlStr
                           params:(NSDictionary *)params
                       cacheBlock:(NetWorkCachesRequest)cacheBlock
                     successBlock:(NetWorkSuccessRequest)successBlock
                        failBlock:(NetWorkFailRequest)failBlock
{
   return [self httpRequestGetDataWithUrl:urlStr params:params requestType:NetWorkRequestGet cacheBlock:cacheBlock successBlock:successBlock failBlock:failBlock];
    
}


- (NSURLSessionTask *)httpRequestPostDataWithUrl:(NSString *)urlStr
                            params:(NSDictionary *)params
                        cacheBlock:(NetWorkCachesRequest)cacheBlock
                      successBlock:(NetWorkSuccessRequest)successBlock
                         failBlock:(NetWorkFailRequest)failBlock
{
    return [self httpRequestGetDataWithUrl:urlStr params:params requestType:NetWorkRequestPost cacheBlock:cacheBlock successBlock:successBlock failBlock:failBlock];
    
}


- (NSURLSessionTask *)httpRequestGetDataWithUrl:(NSString *)urlStr
                           params:(NSDictionary *)params
                      requestType:(NetWorkRequestType)type
                       cacheBlock:(NetWorkCachesRequest)cacheBlock
                     successBlock:(NetWorkSuccessRequest)successBlock
                        failBlock:(NetWorkFailRequest)failBlock
{
    
    NetWorkRequestModel *RequestModel =[[NetWorkRequestModel alloc]init];
    RequestModel.url = urlStr;
    RequestModel.requestType = type;
    if (params && [params isKindOfClass:[NSDictionary class]]) {
        
        RequestModel.parms = params;
    }
    
    if (cacheBlock) {
        RequestModel.cachesBlock = cacheBlock;
    }
    
    if (successBlock) {
        RequestModel.successRequestBlock = successBlock;
    }
    
    if (failBlock) {
        RequestModel.FailRequestBlock = failBlock;
    }
    
    return [[NetWorkTools shareNetWorkTools] requestWithModel:RequestModel];
}

@end
